home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / NEWXDIR.ASM < prev    next >
Assembly Source File  |  1987-04-07  |  43KB  |  841 lines

  1. ;XDIR.COM for the IBM Personal Computer - 1986 by Jeff Prosise
  2. code          segment para public 'code'
  3.               assume cs:code
  4.               org 100h
  5. begin:        jmp initialize                ;goto initialization code
  6. ;
  7. copyright          db 'Copyright 1986 Ziff-Davis Publishing Co.',1Ah
  8. global             db '\*.*',0              ;global directory filespec
  9. dos_segment        dw ?                     ;DOS segment
  10. busy_flag          dw ?                     ;offset of DOS BUSY_FLAG
  11. program_status     db 0                     ;XDIR processing status
  12. flag_13h           db 0                     ;status of interrupt 13h
  13. request_flag       db 0                     ;status of processing request
  14. adapter            db 2                     ;0 = MDA, 1 = CGA, 2 = EGA
  15. video_segment      dw 0B800h                ;video segment address
  16. video_page         db ?                     ;current video page
  17. border_attr        db 4Fh                   ;window border attribute
  18. text_attr          db 0Fh                   ;window text attribute
  19. video_address      dw ?                     ;window start address
  20. cursor_mode        dw ?                     ;cursor shape
  21. cursor_pos         dw ?                     ;cursor position
  22. maxlen             db ?                     ;maximum input string length
  23. max_page           db ?                     ;number of highest directory page
  24. dir_page           db ?                     ;current directory page
  25. end_flag           db ?                     ;status of text write routines
  26. error_flag         db ?                     ;critical error status
  27. default_cursor     dw 0607h                 ;default cursor shape (color)
  28. addr_6845          dw ?                     ;CRT Controller base address
  29. search_attr        dw 0                     ;file search attribute
  30. ;
  31. path               dw 0                          ;pointer to pathname buffer
  32. dta                dw 64                         ;pointer to Disk Transfer Area
  33. screen_buffer      dw offset initialize          ;pointer to screen buffer
  34. text_buffer        dw offset initialize+1536     ;pointer to filename buffer
  35. ;
  36. keyboard_int       label dword              ;old interrupt 9 vector
  37. old9h              dw 2 dup (?)
  38. timer_int          label dword              ;old interrupt 1Ch vector
  39. old1ch             dw 2 dup (?)
  40. bdisk_int          label dword              ;old interrupt 13h vector
  41. old13h             dw 2 dup (?)
  42. bp_int             label dword              ;old interrupt 28h vector
  43. old28h             dw 2 dup (?)
  44. ;
  45. old_dta_segment    dw ?                     ;old DTA segment address
  46. old_dta_offset     dw ?                     ;old DTA offset address
  47. old24h_segment     dw ?                     ;old interrupt 24h routine segment
  48. old24h_offset      dw ?                     ;old interrupt 24h routine offset
  49. enable_values      db 2Ch,28h,2Dh,29h       ;values to enable CGA output
  50.                    db 2Ah,2Eh,1Eh
  51. errtext            db 'No Files Found',0
  52. ;
  53. ;------------------------------------------------------------------------------
  54. ;Execution comes here thru interrupt 9 every time a key is pressed or released.
  55. ;------------------------------------------------------------------------------
  56. keyboard      proc near
  57.               sti                           ;set interrupt enable flag
  58.               push ax                       ;save AX
  59.               in al,60h                     ;get scan code from keyboard
  60.               cmp al,52                     ;was the '.' key pressed?
  61.               jne kb2                       ;no, then exit to normal handler
  62.               mov ah,2                      ;check shift key status
  63.               int 16h
  64.               test al,8                     ;is the Alt key pressed?
  65.               je kb2                        ;no, then exit
  66.               call kb_reset                 ;reset keyboard, issue EOI
  67.               pop ax                        ;restore AX
  68.               cmp program_status,0          ;XDIR routine already active?
  69.               jne kb1                       ;yes, then don't set request flag
  70.               mov request_flag,1            ;set request flag
  71. kb1:          iret                          ;end interrupt routine
  72. kb2:          pop ax                        ;restore AX
  73.               jmp keyboard_int              ;goto original keyboard routine
  74. keyboard      endp
  75. ;
  76. ;------------------------------------------------------------------------------
  77. ;Interrupt 1Ch handling routine.
  78. ;This procedure will now be used to handle int 8 instead of int 1c
  79. ;------------------------------------------------------------------------------
  80. timer         proc near
  81.               pushf                         ;call original routine
  82.               call timer_int
  83.               cmp request_flag,0            ;request flag set?
  84.               je timer1                     ;no, then exit
  85.               push es                       ;save ES and DI
  86.               push di
  87.               mov es,dos_segment            ;get DOS segment in ES
  88.               mov di,busy_flag              ;address of DOS BUSY_FLAG in DI
  89.               cmp byte ptr es:[di],0        ;DOS service currently active?
  90.               pop di                        ;clean up the stack
  91.               pop es
  92.               jne timer1                    ;yes, then we must wait
  93.               cmp flag_13h,0                ;BIOS disk service active?
  94.               jne timer1                    ;yes, then don't interrupt it
  95.  
  96. test_8259_status:
  97.               push   AX                  ;Save altered registers
  98.               push   DX
  99.               mov    DX,20h              ;Port address of 8259 OCW3
  100.               mov    AL,03               ;Set the In-Service Reg. read
  101.                                          ;bits RR=1 and RIS=1
  102.               out    DX,AL               ;Tell 8259 to send ISR on next read
  103.               jmp    short get_mask      ;This causes a 7 clock delay period
  104.                                          ;on the AT to allow time for the 8259
  105.                                          ;to setup the ISR status for us     
  106. get_mask:
  107.               in     AL,DX               ;Get the ISR
  108.               or     AL,AL               ;Set zero flag if no interrupts are
  109.                                          ;being serviced
  110.               pop    DX                  ;Restore the altered registers
  111.               pop    AX
  112.  
  113.               jnz  timer1                ;A hard interrupt is in progress
  114.               mov request_flag,0            ;reset request flag
  115.               call directory                ;invoke directory routine
  116. timer1:       iret                          ;done - exit
  117. timer         endp
  118. ;------------------------------------------------------------------------------
  119. ;------------------------------------------------------------------------------
  120.  
  121.  
  122.  
  123. ;------------------------------------------------------------------------------
  124. ;Interrupt 13h handling routine.
  125. ;------------------------------------------------------------------------------
  126. bdisk         proc far
  127.               inc flag_13h         ;Set the busy flag
  128.               pushf                ;Simulate an interrupt call to the 
  129.               call bdisk_int       ;original disk interrupt routine
  130.               pushf                ;Save returned flags from disk interrupt
  131.               dec flag_13h         ;Clear the busy flag
  132.               popf                 ;Restore disk I/O status flags
  133.               ret 2                ;Far return and discard flags on the stack
  134. bdisk         endp
  135. ;
  136. ;------------------------------------------------------------------------------
  137. ;Interrupt 28h handling routine.
  138. ;------------------------------------------------------------------------------
  139. backproc      proc near
  140.               pushf                         ;call original routine
  141.               call bp_int
  142.               cmp request_flag,0            ;request flag clear?
  143.               je bp1                        ;yes, then exit
  144.               mov request_flag,0            ;clear request flag
  145.               call directo